__author__ = 'vivienfanghua'
from igraph import *
import os
import sys

def main(dir):
    files=os.listdir(dir)
    for i in files:
        if i.endswith(".net"):
            graph=load(dir+"/"+i)
            edge_num=graph.ecount()
            for j in range(100):
                graph_re=graph.rewire(n=7*edge_num,mode="simple")
                file_output=i.strip(".net")+"_"+str(j+1)+"_.net"
                write(graph_re,file_output)
                print(file_output)
if __name__=="__main__":
    if len(sys.argv)<2:
        print("Example: Python dc_random.py C:/Example")
    main(sys.argv[1])
